**** NOTE: REQUIRES st0085_2, vce2way, and boottest
* ssc install st0085_2 
* ssc install boottest
* ssc install vce2way


clear
clear mata
clear matrix
set more off
set matsize 11000
estimates drop _all

set seed 14850

***Call up the WV6 Analysis Dataset
***ADD YOUR DIRECTORY INFORMATION TO THE FILE NAME IN THE CODE BELOW
cd "YOUR PATH HERE"

use "data/data_pereztavits2017.dta", clear

*****************
** Regressions **
*****************

***Table 4, Model 1
xi: logit  ProtectEnvir Strong_FTR i.FixEff0, vce(cluster Country)
eststo model1

xi: logit  ProtectEnvir Strong_FTR i.FixEff0 i.Country i.Year, vce(cluster Country)
eststo model2

vce2way logit ProtectEnvir Strong_FTR i.FixEff0 i.Country i.Year, cluster (Country Year) 
eststo model3

logit ProtectEnvir Strong_FTR i.FixEff0 i.Country i.Year
eststo model4
boottest Strong_FTR, cluster(Country Year) bootclust(Year) weight(webb)
scalar prob = r(p)
estadd scalar prob

xtmelogit  ProtectEnvir Strong_FTR i.FixEff0 || LanguageAtHome:
eststo model5

xtmelogit  ProtectEnvir Strong_FTR i.FixEff0 i.Country i.Year || LanguageAtHome:
eststo model6

esttab model* using "output/table4_1.tex", b(3) se(3) scalar(prob) keep(Strong_FTR) compress replace



***Table 4, Model 2
xi: logit  ProtectEnvir Strong_FTR Unemployed i.IncomeDecile i.HighestEdu MaritalStatus i.FixEff0, vce(cluster Country)
eststo model1

xi: logit  ProtectEnvir Strong_FTR Unemployed i.IncomeDecile i.HighestEdu MaritalStatus i.FixEff0 i.Country i.Year, vce(cluster Country)
eststo model2

vce2way logit ProtectEnvir Strong_FTR Unemployed i.IncomeDecile i.HighestEdu MaritalStatus i.FixEff0 i.Country i.Year, cluster (Country Year) 
eststo model3

logit ProtectEnvir Strong_FTR Unemployed i.IncomeDecile i.HighestEdu MaritalStatus i.FixEff0 i.Country i.Year
eststo model4
boottest Strong_FTR, cluster(Country Year) bootclust(Year) weight(webb)
scalar prob = r(p)
estadd scalar prob

xtmelogit  ProtectEnvir Strong_FTR Unemployed i.IncomeDecile i.HighestEdu MaritalStatus i.FixEff0 || LanguageAtHome:
eststo model5

xtmelogit  ProtectEnvir Strong_FTR Unemployed i.IncomeDecile i.HighestEdu MaritalStatus i.FixEff0 i.Country i.Year || LanguageAtHome:
eststo model6

esttab model* using "output/table4_2.tex", b(3) se(3) scalar(prob) keep(Strong_FTR) nostar compress replace

